#ifndef VECTOR3_DEF_HPP
#define VECTOR3_DEF_HPP

/**
 * @brief  Vector3 三维控件向量
 *
 */

template <typename T>
struct Vector3 {
public:
    T x, y, z;

public:
    Vector3() :
        x(0), y(0), z(0) {
    }
    Vector3(T x, T y, T z) :
        x(x), y(y), z(z) {
    }

    /**
     * @brief vector 是否在 box内 ，不含边界
     * @param boxMin 边界点
     * @param boxMax 边界点
     * @return true 在，false 不在
     */
    inline bool isInBox(const Vector3 &boxMin, const Vector3 &boxMax) const {
        return x > boxMin.x && y > boxMin.y && z > boxMin.z && x < boxMax.x && y < boxMax.y && z < boxMax.z;
    }

    bool operator==(const Vector3 &other) const {
        return z == other.z && y == other.y && x == other.z;
    }

    Vector3 operator*(T val) const {
        Vector3 ret;
        ret.x = x * val;
        ret.y = y * val;
        ret.z = z * val;
        return ret;
    }

    Vector3 operator+(const Vector3 &val) const {
        Vector3 ret;
        ret.x = x + val.x;
        ret.y = y + val.y;
        ret.z = z + val.z;
        return ret;
    }

    Vector3 operator-(const Vector3 &val) const {
        Vector3 ret;
        ret.x = x - val.x;
        ret.y = y - val.y;
        ret.z = z - val.z;
        return ret;
    }
};

#endif // VECTOR3_DEF_HPP
